<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/3/31
 * Time: 10:29
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\api\controller\v1;

use app\Request;
use EasyWeChat\Factory;

trait paymentApi
{
    protected $payment_url = null;
    protected $request;
    public function __construct(Request $request)
    {
        $config = [
            // 必要配置
            'app_id'             => sysconfig('weixin','wx_pay_app_id'),
            'mch_id'             => sysconfig('weixin','wx_pay_mch_id'),
            'key'                => sysconfig('weixin','wx_pay_key'),   // API v2 密钥 (注意: 是v2密钥 是v2密钥 是v2密钥)

            // 如需使用敏感接口（如退款、发送红包等）需要配置 API 证书路径(登录商户平台下载 API 证书)
            'cert_path'          => sysconfig('weixin','wx_pay_cert'), // XXX: 绝对路径！！！！
            'key_path'           => sysconfig('weixin','wx_pay_cert_key'),      // XXX: 绝对路径！！！！
        ];
        $this->payment_url = Factory::payment($config);
        $this->request = $request;
    }
}